package leetcode.周赛.第274场;

import org.junit.Test;

import java.util.*;

/**
 * @author ：zsy
 * @date ：Created 2022/1/2 13:10
 * @description：https://leetcode-cn.com/problems/destroying-asteroids/
 */
public class 摧毁小行星 {
    @Test
    public void test() {
        Solution solution = new Solution();
    }

    class Solution {
        public boolean asteroidsDestroyed(int mass, int[] asteroids) {
            Arrays.sort(asteroids);
            long sum = mass;
            for (int asteroid : asteroids) {
                if (sum < asteroid) return false;
                sum += asteroid;
            }
            return true;
        }
    }
}
